import React, { Component } from 'react'
import { Form, Checkbox, Button } from 'antd';
const createForm = Form.create
const FormItem = Form.Item
const CheckboxGroup = Checkbox.Group;


@Form.create({
  onFieldsChange(props, items) {
    console.log(props)
    console.log(items)
    // props.cacheSearch(items);
  },
})

export default class roleSelect extends Component {
  constructor(props) {
    super(props)
    this.state = {
      loading: false,
      checkedValues: [],
    }
    this.handleSubmit = this.handleSubmit.bind(this)
    this.onChange = this.onChange.bind(this)
  }

  onChange(checkedValues) {
    this.setState({checkedValues: checkedValues})
  }

  //handleOk(){
  //    this.setState({loading: true})
  //    setTimeout(() => {
  //        this.setState({loading: false})
  //    },3000)
  //}

  handleSubmit(e) {
    e.preventDefault();
    this.setState({loading: true})
    setTimeout(() => {
      this.setState({loading: false})
      this.props.handleOkRole(this.state.checkedValues)
    }, 3000)
    //console.log('check:', this.state.checkedValues)
  }

  setBtnArr(btn, show) {
    this.state.btnArr[btn] = show;
  }

  //getClass() {
  //    for(let name in this.state.btnArr){
  //        this.state.btnArr[name]?console.log(name):null;
  //    }
  //}


  render() {
    const { getFieldProps } = this.props.form;
    const plainOptions = ['system1', '通用角色', 'jxj不要改', '浏览角色']
    return (
      <Form horizontal className="CheckboxGroup_jxy">
        <CheckboxGroup options={plainOptions} defaultValue={[]} onChange={this.onChange}/>
        <Button type="primary" onClick={this.handleSubmit} loading={this.state.loading}
                className="center_jxy">确定</Button>
      </Form>

    )
  }
}
